<!DOCTYPE html>
<html>
<head>
    <include file="Public/head" />
</head>
<body>

<div class="ui-wrap">

    <!--s banner-1-->
    <!--s banner-1-->
	<div class="swiper-container swiper-container-1">
	    <div class="swiper-wrapper">
	        <div class="swiper-slide">
	            <img src="__IMG__/Home/gp-2.jpg"/>
	        </div>
	        <div class="swiper-slide">
	            <img src="__IMG__/Home/gp-3.jpg"/>
	        </div>
	    </div>
	    <div class="swiper-pagination swiper-pagination-1"></div>
	</div><!--e banner-1-->
    <!--e banner-1-->

    <div class="ui-title">
        <span>通用票价</span>
    </div>

    <div class="ui-ticket-info">
        <p class='buy-l'>
            <span>票价：</span>
            <i>￥<eq name="type" value="1">{$info.vip_price}<else/>{$info.tickets_price}</eq></i>
        </p>
        <p class='buy-r'>
            <!--<span>总：{$info.tickets_num}</span>-->
            <!--<span>剩余：<i>{$info.num}</i></span>-->
        </p>
    </div>
    <form action="{:U('Tickets/apply')}" method="post" id="myform">
    <div class="ui-ticket-radio">
        <lable for='rd_1'>
        	<span>我是群主</span><span id="rd_text" <neq name="user['lord_id']" value="">hidden</neq>><font color="#f00">(暂无您的信息噢，请先<a href="{:U('Lord/index')}">报名</a>。)</font></span>
        	<input type="radio" name="ck-radio" id="rd_1" value="1" <eq name="type" value="1">checked</eq> />
        </lable>
        <lable for='rd_2'>
            <span>我不是群主</span>
            <input type="radio" name="ck-radio" id="rd_2" value="0" <eq name="type" value="0">checked</eq>  />
        </lable>
    </div>
    
    <div class="ui-from hide">
        <lable class='ui-from-itme'>
            <span>姓名</span>
            <input type="text" name="user_name" class="text_ipt" id="user_name" value="{$user.user_name}" placeholder="请输入姓名" />
        </lable>
        <lable class='ui-from-itme'>
            <span>手机号</span>
            <input type="tel"  name="user_phone" class="text_ipt" id="user_phone" value="{$user.user_phone}" placeholder="您的手机号" maxlength="11" />
        </lable>
        <lable class='ui-from-itme'>
            <span>验证码</span>
            <input type="tel" name="code" id="code" value="" placeholder="您收到的验证码" />
            <input type="hidden" name="recode" id="recode">
            <a href="javascript:;" class="get-btn">获取验证码</a>
            <input type="hidden" id="pay_sn" value="{$out_trade_no}">
        </lable>
    </div>
    </form>

    <div class="ui-title">
        <span>门票价值</span>
    </div>

    <ul class="ui-ticket-item">
        <li>1.大会入场门票</li>
        <li>2.全套会议文件资料一套</li>
        <li>3.午餐券一张</li>
        <li>4.价值2000元参会礼品包一份</li>
        <li>5.花木世界蒙古包烤全羊餐券</li>
        <li>6.花木世界篝火、烟花、音乐party入场券</li>
        <li>7.25日晚到会嘉宾统一安排食宿</li>
        <li>8.26日晚指定酒店住宿票</li>
        <li>9.2016年3月花木世界花季活动特邀嘉宾资格</li>
        <li>10.花木世界别墅土地众筹优先名额</li>
    </ul>

    <div class="ui-title">
        <span>爆料台</span>
    </div>

    <div class="ui-ticket-disclose">
        <div class="disclose-img">
            <img src="__IMG__/Home/ticket-disclose.png"/>
        </div>
        <div class="ui-disclose-info">
            {$info.projects}
        </div>
    </div>
    <input type="hidden" id="user" value="{$user.lord_id}">
    <input type="hidden" id="order_id" value="{$order.order_id}">
    <input type="hidden" id="type" value="{$type}">
    <a href="javascript::" class="ui-from-submit visibility">购票</a>
    <a href="javascript:" class="ui-from-submit show" onclick="check();">购票</a>

</div>
<script type="text/javascript">

    function check(){
        if($('#order_id').val() != ""){
            alert('你已经购买过门票,不能重复购票!');
            return false;
        }
        if($('#user').val() == "" && $('input[name="ck-radio"]:checked').val()==1){
            alert('您暂时还不是群主,不能购买群主票!');
            return false;
        }
        if($('input[name="ck-radio"]:checked').val()==1){
            callpay();
        }else{
            nextStep();
        }
    }

    function onBridgeReady(){
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
        <?php echo $jsApiParameters; ?>,
        function(res){
            if(res.err_msg == 'get_brand_wcpay_request:ok'){
                $('#myform').submit();
            }
            else{
                alert('支付失败');
            }
        }
    );
    }
    function callpay() {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    }
    $('#rd_1').click(function(){
        if($(this).is(":checked")){
            window.location.href="__APP__/Home/Tickets/order&type=1";
        }
    })
    $('#rd_2').click(function(){
        if($(this).is(":checked")){
            window.location.href="__APP__/Home/Tickets/order&type=0";
        }
    })

    $(function(){
        if($('#rd_1').is(":checked")){
            $('.ui-from').addClass('hide');
        }
        if($('#rd_2').is(":checked")){
//            $('.font_baoming').hide();
            $('.ui-from').removeClass('hide');
        }
        var seed = 60;
        var t;
        var ts = $('.get-btn');
        var bol = true;
        $('.get-btn').click(function(){
            var phone = $('#user_phone').val();
            if(phone == ""){
                alert('手机号码不能为空');
                return false;
            }
            if(bol){
                $.ajax({
                    url:"{:U('Index/ajaxCode')}",
                    type:'post',
                    data:{phone:phone},
                    success:function(result){
                        if(result.status==1){
                            fun();
                            $('#recode').val(result.msg);
                        }else{
                            alert("服务器异常,请联系管理员");
                        }
                    }
                });
            }
        })
        var fun = function(){
            bol = false;
            if(seed>0){
                seed--;
                ts[0].innerHTML = seed+'秒后获取';
                t = setTimeout(fun,1000);
            }else{
                seed = 60;
                bol = true;
                ts[0].innerHTML = '获取验证码';
                clearTimeout(t);
            }
        }
    })
    function nextStep(){
        $("form :input.text_ipt").trigger('blur');
        var numError = $('form .onError').length;
        if(numError){
            return false;
        }
        if($('#lord_name').val()==""){
            alert('群名称不能为空');
            return false;
        }
        if($('#user_name').val()==""){
            alert('群主姓名不能为空');
            return false;
        }
        if($('#user_phone').val()==""){
            alert('联系电话不能为空');
            return false;
        }
        if($('#code').val()==""){
            alert('请填写验证码');
            return false;
        }
        if($('#code').val() != $('#recode').val()){
            alert('验证码错误');
            return false;
        }
        callpay();
    }
</script>
<script language="javascript">
    var mySwiper = new Swiper('.swiper-container',{pagination : '.swiper-pagination',autoplay : 3000})
</script>
</body>
</html>
